﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RepositoryFramework;
using Portal.Repository.SkillsCatalog;

namespace Portal.Repository
{
	/// <summary>
	/// Class <see cref="PortalUnitOfWork"/> define unit of work
	/// </summary>
	public class PortalUnitOfWork : UnitOfWork<PortalEntities>, IPortalUnitOfWork
	{
		#region Fields
		private IContactInfoRepository _contactInfoRepository;
		private IUserRepository _userRepository;
		#endregion

		#region Properties
		/// <summary>
		/// Gets the contact information repository.
		/// </summary>
		/// <value>
		/// The contact information repository.
		/// </value>
		public IContactInfoRepository ContactInfoRepository
		{
			get
			{
				if (_contactInfoRepository == null)
				{
					_contactInfoRepository = new ContactInfoRepository(Context);
				}
				return _contactInfoRepository;
			}
		}

		/// <summary>
		/// User repository
		/// </summary>
		public IUserRepository UserRepository
		{
			get
			{
				if (_userRepository == null)
				{
					_userRepository = new UserRepository(Context);
				}
				return _userRepository;
			}
		}
		#endregion

		#region .ctor
		/// <summary>
		/// Initializes a new instance of the <see cref="UnitOfWork"/> class.
		/// </summary>
		public PortalUnitOfWork()
			: base(new PortalEntities())
		{
		}
		#endregion
	}
}
